#ifndef PATH_ITERATOR_H_
#define PATH_ITERATOR_H_

#include <list>
#include "point.h"
#include "ifollower.h"

class Path;

class PathIterator{
	private:
		Point current;
		Point last;
		Point initial;
		unsigned int step;
		bool loop;
		unsigned int count;
		std::list<IFollower*> followers;
		unsigned int newStep;

		friend class Path;
	public:
		PathIterator(){
			this->current=Point(0,0,0);
			this->initial=Point(0,0,0);
			this->step=1;
			this->loop=false;
			this->count=0;
			this->newStep=0;
		}

		PathIterator(Point p,unsigned int s,bool l){
			this->current=Point(0,0,0);
			this->initial=p;
			this->step=s;
			this->loop=l;
			this->count=0;
			this->newStep=0;
		}

		Point getCurrent()const{
			return this->current;
		}

		Point getInitial()const{
			return this->initial;
		}

		Point getLast()const{
			return this->last;
		}

		void setNewStep(unsigned int delta_step){
			int w = this->newStep;
			if(this->newStep==0)
				w = this->step+delta_step;
			else
				w += delta_step;

			if(w<=0)
				this->newStep=1;
			else
				this->newStep=w;
		}

		float getNewStep(){
			return this->newStep;
		}

	private:
		void updateFollowers(){
			for(std::list<IFollower*>::iterator it=followers.begin();it!=followers.end();++it){
				(*it)->updatePosition(*this);
			}
		}
};


#endif /* PATH_ITERATOR_H_ */
